package cn.javabb.core.model;

/**
 * @Author QINB imqinbao@163.com
 * @CreateDate 2019/1/3/003 9:26
 * @Since V1.0
 */
public enum StatusEnum {
    NORMAL(0,"启用"),
    ABNORMAL(1,"禁用"),
    DELETE(-1,"删除"),
    ;
    private int code;
    private String desc;

    StatusEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static StatusEnum get(Integer code){
        if(null == code){
            return ABNORMAL;
        }
        StatusEnum[] statusEnums = StatusEnum.values();
        for (StatusEnum statusEnum : statusEnums) {
            if (statusEnum.getCode() == code) {
                return statusEnum;
            }
        }
        return ABNORMAL;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }
}
